<?php
namespace app\common\behavior;
use think\Exception;
use think\Lang;
use think\Loader;
use think\Request;

class Capital 
{
	/**
     * [afterCapitalOperation description]
     * @param  [type] &$info [description]
     * @return [type]        [description]
     */
    public function afterCapitalOperation(&$info)
    {
        //$info['amount'] types remark
    	try {
            Request::instance()->langset(Lang::range());
            Lang::load([
                THINK_PATH . 'lang' . DS . Request::instance()->langset() . EXT,
                APP_PATH . 'lang' . DS . Request::instance()->langset() . EXT,
            ]);
            $notice_instance = \services\notices\Notice::instance();
            $user_info       = Loader::model('common/Users')->getUserInfo($info['user_id']);

            $notice['title']   = Lang::get('Your funds are subject to change');
            $notice['content'] = Lang::get('Notice of change of member funds', ['type' => Lang::get($info['types']), 'amount' => $info['amount'], 'remark' => $info['remark']]);

            if ($user_info->email) {
                $recipients['mail'] = $user_info->email;
                //$notice_instance->mail->send($user_info->email, $notice['title'], $notice['content']);
            }

            $recipients['sign'] = $user_info->sign;

            $notice_instance->send($recipients, $notice['title'], $notice['content']);
    	} catch (\Exception $e) {
    		//throw $e;
    	}
        
    }
}